#include"../server.hpp"

int main()
{
    signal(SIGCHLD, SIG_IGN);
    string info = "hello server! ";
    for(int i = 0; i < 5; i++)
    {
        Socket sock;
        sock.ClinetConnect(8088, "111.231.79.105");        
        pid_t ret = fork();
        assert(ret != -1);

        if(ret == 0)
        {
            while(1)
            {
                cout << "client says: " << info << endl;
                sock.Send((char*)info.c_str(), info.size());

                char buffer[1024] = {0};
                sock.Recv(buffer, sizeof(buffer));

                cout << "server echo: " << buffer << endl;
                sleep(1);        
            }
        }
        
    }
    
    // while(1)
    // {
    //     cout << "client says: " << info << endl;
    //     sock.Send((char*)info.c_str(), info.size());

    //     char buffer[1024] = {0};
    //     sock.Recv(buffer, sizeof(buffer));

    //     cout << "server echo: " << buffer << endl;
    //     sleep(1);        
    //}

    // for(int i = 0; i < 5; i++)
    // {
    //     cout << "client says: " << info << endl;
    //     sock.Send((char*)info.c_str(), info.size());

    //     char buffer[2048];
    //     sock.Recv(buffer, sizeof(buffer));
    //     cout << "server echo: " << buffer << endl;
    //     sleep(1);        
    // }
    while(1);
    return 0;
}